package sample.testMaterialList
{

	import org.abc.uiCore.AbcBindView;
	import org.abc.uiCore.vo.CpVo;
	import org.abc.uiCore.list.ListModel;
	import org.abc.interfaces.IListView;
	import org.abc.manager.DebugManager;

	import com.bit101.components.PushButton;
	import com.demonsters.debugger.MonsterDebugger;

	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.MouseEvent;

	import sample.ItemCP_CPS;

	/**
	 * @描述
	 * @作者		Mr.zheng
	 * @版本		version 1.0
	 * @创建日期	2011-8-25 10:32
	 */
	public class TestMaterialList extends Sprite
	{
		private var _materialList:MaterialList_CPS;
		private var _model:ListModel;

		public function TestMaterialList()
		{
			_model=new ListModel();
			var vo:CpVo;
			for (var i:int=0; i < 10; i++)
			{
				vo=new CpVo();
				vo.data["id"]=100 + i;
				_model.append(vo);
			}
			_materialList=new MaterialList_CPS(ItemCP_CPS, _model);

			this.addChild(_materialList as DisplayObject);

			var nextPage:PushButton=new PushButton(this, 100, 130, "nextPage", onNextPage);
			var prePage:PushButton=new PushButton(this, 10, 130, "prePage", onPrePage);

			var addNode:PushButton=new PushButton(this, 10, 160, "addNode", onAddNode);
			var delNode:PushButton=new PushButton(this, 110, 160, "delNode", onDelNode);

			DebugManager.instance.init(stage);
		}

		private function onNextPage(e:MouseEvent):void
		{
			_materialList.list.nextPage();
		}

		private function onPrePage(e:MouseEvent):void
		{
			_materialList.list.prePage();
		}

		private function onAddNode(e:MouseEvent):void
		{
			var vo:CpVo=new CpVo();
			vo.data["id"]="add";
			_model.append(vo);
		}

		private function onDelNode(e:MouseEvent):void
		{
			_model.removeTail();
		}

	}

}
